import java.util.Random;

/*1：随机生成六个1-10（包含10）之间的数存入数组中,
        然后计算出去掉最大值与最小值的平均数，
        输出格式如下*/
public class Test01 {
    public static void main(String[] args) {
     int arr[] = new int[6];
        Random r = new Random();
        for (int i = 0; i < arr.length; i++) {//生成随机数并定界
            int a = r.nextInt(10)+1;
            arr[i]=a;
        }int max =arr[0];int min  =arr[0];int sum =0;
        for (int i = 0; i < arr.length; i++) {//遍历取得最值与和
           max= arr[i]>max?arr[i]:max;
           min = arr[i]<min?arr[i]:min;
           sum+=arr[i];

        }
        System.out.println("数组中的数据为");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
            if(i==arr.length-1){
                System.out.println(arr[i]);
            }
        }
        System.out.println("最小值为 = " + min);//最终得到平均值
        System.out.println("最大值为 = " + max);
        double avg = (sum-max-min)/(arr.length-2);
        System.out.println("平均值为 = " + avg);
    }
}